/**
 *
 */
package com.hexacta.hrs.services.staffing.impl.predicates;

import java.util.Date;

import org.apache.commons.collections.Predicate;
import org.vectrics.common.util.DateUtil;

import com.hexacta.hrs.domain.staffing.Requirement;

/**
 * @author ldeveikis
 *
 */
public class DateRequirementPredicate implements Predicate {

	/*
	 * (non-Javadoc)
	 *
	 * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
	 */
	private Date from;
	private Date to;

	private DateRequirementPredicate() {
	}

	public DateRequirementPredicate(Date from, Date to) {
		this.from = from;
		this.to = to;
	}

	@Override
	public boolean evaluate(Object object) {
		return ((object instanceof Requirement) && (DateUtil
				.areDatesOverlapped(this.from, this.to, ((Requirement) object)
						.getStartDate().getTime(), ((Requirement) object)
						.getEndDate().getTime())));
	}
}
